import React, { Component } from 'react';
import { NavBar, Form, Input, Button, } from 'antd-mobile'
import "../styles/Register.scss"
import * as service from "../api/index"


class Register extends Component {
    constructor(props) {
        super(props);
        this.state = {};
    }
    async dianji(Values) {
        var res = await service.user_docheckphone(Values)
        if (res.data.code == '200') {
            this.props.history.push({ pathname: '/register2', state: Values });//跳路由传参
            // console.log(this.props.history.location.state)
            alert(res.data.message)

        } else {
            this.props.history.push('/register')
        }

    }

    render() {
        return (
            <div className='register'>
                <div className="top">
                    <NavBar onBack={() => { this.props.history.go(-1) }} ><p>注册</p></NavBar>
                </div>
                <div className="box1">
                    <Form
                        autoComplete='off'
                        requiredMarkStyle='none'
                        onFinish={(Values) => { console.log(Values); this.dianji(Values) }}
                        footer={
                            <Button block type='submit' color='primary' size='large'>
                                下一步
                            </Button>
                        }>
                        <Form.Item name='tel'
                            rules={[{
                                required: true,
                                pattern: /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/,
                                message: '手机号码不能为空'
                            }]}
                        >
                            <Input placeholder='请输入手机号' />
                        </Form.Item>
                    </Form>
                </div>
            </div>
        );
    }
}

export default Register;